package com.monlyu.action.mail;

import java.util.List;

import com.monlyu.action.PageAction;
import com.monlyu.bean.Pages;
import com.monlyu.bo.MailBo;
import com.monlyu.util.WebOptUtil;
import com.monlyu.vo.Mail;
import com.monlyu.vo.User;

/********************************************************************************
 * 
 * <b>功能描述☞</b><br>
 * 
 * <b>开发公司☞</b>重庆唯尼科技有限公司<br>
 * <b>版权☞</b>本文件归重庆唯尼科技有限公司所有<br>
 * <b>项目名☞</b>NewsSys<br>
 * <b>文件路径☞</b>com.monlyu.action.mail.ListMailAction.java<br>
 * <b>开发日期☞</b>2010-2-24 <br>
 * 
 * @author zengjun
 * @since JDK 5
 * @version 1.0.8
 * 
 ********************************************************************************/
public class ListMailAction extends PageAction {

	private String mailFlag;

	private Mail mail;

	private MailBo mailBo;

	private List<User> users;

	private Pages<Mail> mails;

	public void setMailBo(MailBo mailBo) {
		this.mailBo = mailBo;
	}

	public String getMailFlag() {
		return mailFlag;
	}

	public Mail getMail() {
		return mail;
	}

	public void setMail(Mail mail) {
		this.mail = mail;
	}

	public void setMailFlag(String mailFlag) {
		this.mailFlag = mailFlag;
	}

	public Pages<Mail> getMails() {
		return mails;
	}

	public List<User> getUsers() {
		return users;
	}

	public String execute() {

		return ajax();
	}

	public String show() {
		mailBo.changeStatus(mail,Mail.MAIL_STATUS_READ);
		return view("mailDetail.jsp");
	}

	public String newMail() {
		if (mail != null && mail.getReceiver() != null) {
			mailBo.load(mail.getReceiver());
		}
		mailFlag = "newMail";
		users = mailBo.findOtherUsers();
		return view("mailHome.jsp");
	}

	/**
	 * 收件箱
	 * 
	 * @return
	 */
	public String receiveMail() {
		mailFlag = "receiveMail";
		mails = mailBo.getReceivedMails(WebOptUtil.curUser(), getDefPage());
		return view("mailHome.jsp");
	}

	/**
	 * 已发送邮件
	 * 
	 * @return
	 */
	public String sendedMail() {
		mailFlag = "sendedMail";
		mails = mailBo.getSendMails(WebOptUtil.curUser(), getDefPage());
		return view("mailHome.jsp");
	}

	/**
	 * 垃圾箱
	 * 
	 * @return
	 */
	public String deletedMail() {
		mailFlag = "deletedMail";
		mails = mailBo.getDeletedMails(WebOptUtil.curUser(), getDefPage());
		return view("mailHome.jsp");
	}

	public String home() {
		return view("mailHome.jsp");
	}
}
